<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Math随机数</title>
</head>

<body>
  <script>
    //取随机整数0~10

    console.log(Math.floor(Math.random() * (10 + 1)))

    //取随机整数0~15

    console.log(Math.floor(Math.random() * (10 + 1) + 5))

    //取随机整数4~12
    // console.log(Math.floor(Math.random() * (差值 + 1) + 最小值))

    console.log(Math.floor(Math.random() * (8 + 1) + 4))


  </script>
</body>

</html>